package cn.ihelloworld.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ihelloworld.bean.SysUser;
import cn.ihelloworld.dao.ISysUserDao;
import cn.ihelloworld.dao.Pagation;
import cn.ihelloworld.service.ISysUserService;

@Repository
@Transactional
public class SysUserServiceImpl implements ISysUserService {

	@Autowired
	private ISysUserDao userDao;
	
	@Override
	public SysUser get(String id) {
		// TODO Auto-generated method stub
		return userDao.get(id);
	}

	@Override
	public List<SysUser> select(SysUser t) {
		// TODO Auto-generated method stub
		return userDao.select(t);
	}

	@Override
	public Pagation<SysUser> selectForPage(SysUser t, int currentPage,
			int pageSize) {
		// TODO Auto-generated method stub
		return userDao.selectForPage(t, currentPage, pageSize);
	}

	@Override
	public void saveOrUpdate(SysUser t) {
		// TODO Auto-generated method stub
		userDao.saveOrUpdate(t);
	}

	@Override
	public void delete(String id) {
		// TODO Auto-generated method stub
		userDao.delete(id);
	}

	@Override
	public void delete(String[] ids) {
		// TODO Auto-generated method stub
		userDao.delete(ids);
	}

	@Override
	public SysUser login(SysUser user) {
		List<SysUser> list=userDao.select(user);
		if(list==null||list.size()==0){
			return null;
		}
		return list.get(0);
	}

	@Override
	public void saveOrUpdate(List<SysUser> list) {
		// TODO Auto-generated method stub
		for(SysUser user:list){
			userDao.saveOrUpdate(user);
		}
	}

}
